﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace ShoppingList.DTO
{
    public class ShoppingItem : Entity
    {
        private bool isScheduled, isCompleted;
        private Category category;
        private string name = string.Empty;


        public Category Category
        {
            get { return category; }
            set
            {
                if (category != value)
                {
                    category = value;
                    OnPropertyChanged("Category");
                }
            }
        }

        public bool IsScheduled
        {
            get { return isScheduled; }
            set
            {
                if (isScheduled != value)
                {
                    isScheduled = value;
                    IsCompleted = false;
                    OnPropertyChanged("IsScheduled");
                }
            }
        }

        public bool IsCompleted
        {
            get { return isCompleted; }
            set
            {
                if (isCompleted != value)
                {
                    isCompleted = value;
                    OnPropertyChanged("IsCompleted");
                    if (value) IsScheduled = false;
                }
            }
        }

        public string Name
        {
            get { return name; }
            set
            {
                if (name != value)
                {
                    name = value;
                    OnPropertyChanged("Name");
                }
            }
        }

        public ShoppingItem(string name)
            : base()
        {
            if (name == null) throw new ArgumentNullException("name");
            isCompleted = true;
            this.name = name;
        }

        public ShoppingItem(int id, bool isScheduled, bool isCompleted, string name, Category category)
            : base()
        {
            if (name == null) throw new ArgumentNullException("name");
            this.id = id;
            this.isScheduled = isScheduled;
            this.isCompleted = isCompleted;
            this.category = category;
            this.name = name;
        }

    }
}
